﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace QuotationService.RealtimeQuotation
{
    /// <summary>
    /// 逐笔信息
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
    internal struct OptionTickInfo
    {
        /// <summary>
        /// Tick序号
        /// </summary>
        public Int32 TickSN;

        /// <summary>
        /// 成交时间
        /// </summary>
        public Int32 KnockTime;

        /// <summary>
        /// 成交价格
        /// </summary>
        public double KnockPrice;

        /// <summary>
        /// 成交数量
        /// </summary>
        public Int64 KnockQty;

        /// <summary>
        /// 最高价
        /// </summary>
        public double HighPrice;

        /// <summary>
        /// 最低价
        /// </summary>
        public double LowPrice;

        /// <summary>
        /// 涨跌值
        /// </summary>
        public double Diff;

        /// <summary>
        /// 涨跌幅
        /// </summary>
        public double DiffRate;

        /// <summary>
        /// 总买量
        /// </summary>
        public Int64 TotalBuyQty;

        /// <summary>
        /// 总买差量
        /// </summary>
        public Int64 TotalBuyQtyDiff;

        /// <summary>
        /// 总卖量
        /// </summary>
        public Int64 TotalSellQty;

        /// <summary>
        /// 总卖差量
        /// </summary>
        public Int64 TotalSellQtyDiff;

        /// <summary>
        /// 委差
        /// </summary>
        public Int64 VolumeDiff;

        /// <summary>
        /// 委比
        /// </summary>
        public double VolumeRate;

        /// <summary>
        /// 总成交数量
        /// </summary>
        public Int64 TotalKnockQty;

        /// <summary>
        /// 成交金额
        /// </summary>
        public double KnockAmt;

        /// <summary>
        /// 总成交金额
        /// </summary>
        public double TotalKnockAmt;

        /// <summary>
        /// 成交均价
        /// </summary>
        public double KnockAvgPrice;

        /// <summary>
        /// 当前持仓
        /// </summary>
        public Int64 OpenPosition;

        /// <summary>
        /// 仓差
        /// </summary>
        public Int64 PositDiff;

        /// <summary>
        /// 买卖性质
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.BSTypeLength)]
        public string BSType;


        /// <summary>
        /// 理论价格
        /// </summary>
        public double TheoreticalPrice;

        /// <summary>
        /// 衡量标的资产价格变动时，期权价格的变化幅度
        /// </summary>
        public double Delta;

        /// <summary>
        /// 衡量标的资产价格变动时，期权Delta值的变化幅度
        /// </summary>
        public double Gamma;

        /// <summary>
        /// 衡量随着时间的消逝，期权价格的变化幅度
        /// </summary>
        public double Theta;

        /// <summary>
        /// 衡量标的资产价格波动率变动时，期权价格的变化幅度
        /// </summary>
        public double Vega;

        /// <summary>
        /// 衡量利率变动时，期权价格的变化幅度
        /// </summary>
        public double Rho;

        /// <summary>
        /// 隐含波动率
        /// </summary>
        /// <remarks>
        /// 当无法计算出隐含波动率时，会将此属性赋值为double.NaN
        /// </remarks>
        public double IV;


    }
}
